package com.xunyin.modules.mtstore.service.mapper;


import com.xunyin.common.mapper.CoreMapper;
import com.xunyin.modules.mtstore.domain.MtStaff;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * 店铺员工表 Mapper 接口
 * <p>
 * Created by xunyinyunshang <3594419785@qq.com>
 * CopyRight 讯音云商 https://www.tonetn.com
 */
@Repository
public interface MtStaffMapper extends CoreMapper<MtStaff> {

    @Update("update mt_staff p set p.AUDITED_STATUS = #{status}, p.UPDATE_TIME = #{updateTime} where p.ID = #{id}")
    int updateStatus(@Param("id") Integer id, @Param("status") String status, @Param("updateTime") Date updateTime);

    @Select("select * from mt_staff t where t.MOBILE = #{mobile}")
    MtStaff queryStaffByMobile(@Param("mobile") String mobile);

    @Select("select * from mt_staff t where t.MOBILE = #{mobile} and t.audited_status='A' and t.is_del=0 and t.CATEGORY in(1,2) limit 1")
    MtStaff queryNormalStaffByMobile(@Param("mobile") String mobile);

    @Select("select * from mt_staff t where t.MOBILE = #{mobile} and t.audited_status='A' ")
    List<MtStaff> queryStaffListByMobile(@Param("mobile") String mobile);

    @Select("select * from mt_staff t where t.USER_ID = #{userId}")
    MtStaff queryStaffByUserId(@Param("userId") Integer userId);
}
